package com.socialin.android.hackaton.draw.util;

import java.io.ByteArrayOutputStream;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;

public class Util {
	public static String toBase64(Bitmap bmp) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();  
		bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);
		byte[] b = baos.toByteArray(); 
		
		return Base64.encodeToString(b, Base64.URL_SAFE);
	}
	
	public static Bitmap getBitmapFromBase64(String data) {
		byte[] bytes = Base64.decode(data.getBytes(), Base64.DEFAULT);
		return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
	}
}
